using Holoville.HOTween;
using I2.Loc;
using UnityEngine;

public class ExpHUD : MonoBehaviour
{
	public static ExpHUD instance;

	[Header("Main Menu")]
	public UILabel levelLabel;

	public UILabel levelLabel2;

	public GameObject progressBar;

	public GameObject progressBar2;

	public UISprite levelIconMainMenu;

	public UILabel levelNameMainMenu;

	[Header("Profile Panel")]
	private UIWidget widgetPanel;

	private string term;

	private void Awake()
	{
		instance = this;
	}

	private void Start()
	{
		HOTween.Init();
		widgetPanel = GetComponent<UIWidget>();
		progressBar.GetComponent<TweenColor>().ResetToBeginning();
		if (!settings.learningCompleted)
		{
			base.gameObject.SetActive(false);
		}
		SwitchLanguage.onChangeLanguage += SetLevelName;
		if (progressBar2 != null)
		{
			progressBar2.GetComponent<UISprite>().fillAmount = CupsManager.GetLeagueFillAmount;
		}
		SetLevelLabel(0);
	}

	public void RefreshForPannelProfile()
	{
	}

	private void OnDestroy()
	{
		instance = null;
		SwitchLanguage.onChangeLanguage -= SetLevelName;
	}

	public void SetExpirienceBar(float currentExp, float maxExp)
	{
		ShowIndicator();
		float getLeagueFillAmount = CupsManager.GetLeagueFillAmount;
		progressBar.GetComponent<TweenColor>().Play();
		if (progressBar2 != null)
		{
			progressBar2.GetComponent<UISprite>().fillAmount = getLeagueFillAmount;
		}
	}

	public void ResetTweener()
	{
		progressBar.GetComponent<TweenColor>().ResetToBeginning();
	}

	public void SetLevelLabel(int level)
	{
		levelLabel.text = CupsManager.CurrentLeague.ToString();
		if (levelLabel2 != null)
		{
			levelLabel2.text = level.ToString();
		}
		SetLevelIcon(string.Empty);
		SetLevelName(string.Empty);
	}

	public void SetLevelIcon(string iconName)
	{
		if ((bool)levelIconMainMenu)
		{
			levelIconMainMenu.spriteName = iconName;
		}
	}

	public void SetLevelName(string levelName)
	{
		term = levelName;
		if ((bool)levelNameMainMenu)
		{
			levelNameMainMenu.text = LocalizationManager.GetTermTranslation("Game_Reputation/" + levelName);
		}
	}

	public void SetLevelName()
	{
		SetLevelName(term);
	}

	public void HideIndicator()
	{
		if (!(GameController.instance == null))
		{
			HOTween.To(widgetPanel, 1f, new TweenParms().Prop("alpha", 0f).Ease(EaseType.Linear).Delay(5f));
		}
	}

	public void ShowIndicator()
	{
		if (!(GameController.instance == null))
		{
			HOTween.Kill(widgetPanel);
			HOTween.To(widgetPanel, 0.2f, new TweenParms().Prop("alpha", 1f).Ease(EaseType.Linear));
			HideIndicator();
		}
	}
}
